package pers.sen.health.controller;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import pers.sen.health.entity.Result;
import pers.sen.health.poi.POIUtils;
import pers.sen.health.service.OrderSettingService;

import java.util.List;

/**
 * @author Jason
 * @version 1.0.0
 * @date 2020/11/9 19:18
 * @Description TODO
 */
@RestController
public class OrderSettingController {

    @Reference
    private OrderSettingService orderSettingService;


    @PostMapping("ordersetting/importOrderSettings")
    public Result importOrderSettings(@RequestParam("excelFile") MultipartFile file){
        // 将excel表格中的数据读取到集合中
        List<String[]> excel = POIUtils.readExcel(file);
        orderSettingService.importOrderSettings(excel);
        return new Result(true);
    }

    @GetMapping("ordersetting/findSettingData/{year}/{month}")
    public Result findSettingData(@PathVariable("year") int year, @PathVariable("month") int month){
        return new Result(orderSettingService.findSettingData(year,month));
    }

    @PutMapping("ordersetting/updateNumberByOrderdate/{number}/{settingDay}")
    public Result updateNumberByOrderdate(@PathVariable("number") int number,@PathVariable("settingDay") String settingDay){
        return   new Result(orderSettingService.updateNumberBySettingDay(number,settingDay));
    }

}
